package com.smritimap.demo.view;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.view.View;

/**
 * Created by zxn on 2024/12/17.
 */
public class ArcView extends View {
    private Paint paint;
    private RectF rectF;

    public ArcView(Context context) {
        super(context);
        init();
    }

    public ArcView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    public ArcView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init();
    }

    private void init() {
        paint = new Paint();
        paint.setColor(Color.BLUE);
        paint.setAntiAlias(true);
        paint.setStyle(Paint.Style.STROKE);
        paint.setStrokeWidth(10);

        rectF = new RectF();
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);

        // 设置绘制弧形的坐标和大小
        rectF.set(50, 50, 250, 250);

        // 设置起始角度、扫过的角度（单位为度）
        float startAngle = 0;
        float sweepAngle = 270;

        // 绘制圆形弧
        canvas.drawArc(rectF, startAngle, sweepAngle, true, paint);
    }
}
